<template>
  <view class="main dispaly-col-center">
    <view class="title">{{detail?.noticeTitle}}</view>
    <view class="time">{{detail?.createTime}}</view>
    <view class="con">{{title}}</view>
<!--    <view class="detail" v-if="detail.noticeTitle == '议价通知'" @click="skipDetail">前往详情</view>-->
  </view>
</template>

<script setup>
import {ref} from 'vue';
import {msgDetail} from '@/api/apiList';
import {onLoad} from '@dcloudio/uni-app'

const id = ref('')
onLoad((option) => {
  id.value = option.id ? option.id : ''
  getDetail()
})

const detail = ref({})
const title = ref('')
const getDetail = async () => {
  const res = await msgDetail(id.value)
  if(res.code == 200) {
    detail.value = res.data
    title.value = JSON.parse(detail.value.noticeContent).message
  }
}

const skipDetail = () => {
  const data = JSON.parse(detail.value.noticeContent)
  if(detail.value.noticeTitle == "议价通知") {
    if(data.type == 0) {
      uni.navigateTo({
        url: `/subPackage/index/bookDetail?id=${data.id}`
      })
    }else {
      uni.navigateTo({
        url: `/subPackage/index/bookDetail?id=${data.id}`
      })
    }
  }else {

  }
}
</script>

<style lang="scss" scoped>
.main {
  padding: 22rpx;
  .detail {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 240rpx;
    height: 70rpx;
    background-color: #ffd257;
    margin-top: 30rpx;
    border-radius: 40rpx;
    font-size: 35rpx;
  }
  .title {
    font-weight: 900;
    font-size: 30rpx;
    margin-bottom: 10rpx;
  }
  .time {
    font-size: 23rpx;
    margin: 20rpx 0;
  }
  .con {
    font-weight: 700;
    font-size: 26rpx;
    margin-top: 10rpx;
  }
}
</style>